package com.atguigu.lease.common.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * projectName: com.atguigu.lease.common.handler
 *
 * @author: wangs
 * description:
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        // 自动填充，添加时间 的属性值
        this.strictInsertFill(metaObject,"createTime", Date.class,new Date());
        // 自动填充，是否被删除 的属性值
        this.strictInsertFill(metaObject,"isDeleted", Byte.class,(byte) 0);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        // 自动填充，更新时间 的属性值
        this.strictUpdateFill(metaObject,"updateTime", Date.class,new Date());
    }
}
